function script_pca_bayes_2(dim)

data = load('data.mat');
rgb1 = data.rgb1;
rgb2 = data.rgb2;
rgb3 = data.rgb3;
rgb4 = data.rgb4;
rgb1_t = data.rgb1_t;
rgb2_t = data.rgb2_t;
rgb3_t = data.rgb3_t;
rgb4_t = data.rgb4_t;

disp('1 vs 2');
X = vertcat(rgb1, rgb2);
p = pca(X', dim);
c1_2 = p.W'*X';
c1_2 = c1_2';
c1 = c1_2(1:length(rgb1),:);
c2 = c1_2(length(rgb1)+1:end,:);
c1_t = p.W'*rgb1_t'; c1_t = c1_t';
c2_t = p.W'*rgb2_t'; c2_t = c2_t';
[failure success] = bayes_2(c1, c2, c1_t, 1);
[failure success] = bayes_2(c1, c2, c2_t, 2);



str = sprintf('\n1 vs 3');
X = vertcat(rgb1, rgb3);
p = pca(X', dim);
c1_2 = p.W'*X';
c1_2 = c1_2';
c1 = c1_2(1:length(rgb1),:);
c2 = c1_2(length(rgb1)+1:end,:);
c1_t = p.W'*rgb1_t'; c1_t = c1_t';
c2_t = p.W'*rgb3_t'; c2_t = c2_t';
disp(str);
[failure success] = bayes_2(c1, c2, c1_t, 1);
[failure success] = bayes_2(c1, c2, c2_t, 2);



str = sprintf('\n1 vs 4');
X = vertcat(rgb1, rgb4);
p = pca(X', dim);
c1_2 = p.W'*X';
c1_2 = c1_2';
c1 = c1_2(1:length(rgb1),:);
c2 = c1_2(length(rgb1)+1:end,:);
c1_t = p.W'*rgb1_t'; c1_t = c1_t';
c2_t = p.W'*rgb4_t'; c2_t = c2_t';
disp(str);
[failure success] = bayes_2(c1, c2, c1_t, 1);
[failure success] = bayes_2(c1, c2, c2_t, 2);


str = sprintf('\n2 vs 3');
X = vertcat(rgb2, rgb3);
p = pca(X', dim);
c1_2 = p.W'*X';
c1_2 = c1_2';
c1 = c1_2(1:length(rgb2),:);
c2 = c1_2(length(rgb2)+1:end,:);
c1_t = p.W'*rgb2_t'; c1_t = c1_t';
c2_t = p.W'*rgb3_t'; c2_t = c2_t';
disp(str);
[failure success] = bayes_2(c1, c2, c1_t, 1);
[failure success] = bayes_2(c1, c2, c2_t, 2);


str = sprintf('\n2 vs 4');
X = vertcat(rgb2, rgb4);
p = pca(X', dim);
c1_2 = p.W'*X';
c1_2 = c1_2';
c1 = c1_2(1:length(rgb2),:);
c2 = c1_2(length(rgb2)+1:end,:);
c1_t = p.W'*rgb2_t'; c1_t = c1_t';
c2_t = p.W'*rgb4_t'; c2_t = c2_t';
disp(str);
[failure success] = bayes_2(c1, c2, c1_t, 1);
[failure success] = bayes_2(c1, c2, c2_t, 2);


str = sprintf('\n3 vs 4');
X = vertcat(rgb3, rgb4);
p = pca(X', dim);
c1_2 = p.W'*X';
c1_2 = c1_2';
c1 = c1_2(1:length(rgb3),:);
c2 = c1_2(length(rgb3)+1:end,:);
c1_t = p.W'*rgb3_t'; c1_t = c1_t';
c2_t = p.W'*rgb4_t'; c2_t = c2_t';
disp(str);
[failure success] = bayes_2(c1, c2, c1_t, 1);
[failure success] = bayes_2(c1, c2, c2_t, 2);

end